

import java.io.IOException;
import java.io.RandomAccessFile;
import java.lang.reflect.InvocationTargetException;

import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 描述
 * yanglh
 * 2017/7/14 0014 16:29
 */
public class test2 {
    public static void main(String[] args) throws InterruptedException, IOException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        String allowOrigins = "http://172.18.17.150:3000,http://test.changtu.com:8089,http://minimal-test.changtu.com,http://suningtest-m.changtu.com,http://localhost:8080,http://localhost:8099,http://172.18.5.15:8090,http://cooperate-test.changtu.com,http://test.alifuwu.changtu.com,https://openapi.alipay.com,http://test.weixin.changtu.com,http://localhost:3000,http://127.0.0.1:3000,http://fanliling.free.ngrok.cc,http://172.19.3.52:3001,http://localhost:3000,http://192.168.2.32:3000,http://172.18.5.44:3000,http://172.18.15.28:3000,http://172.18.5.91:8081,http://172.18.17.150:8099,http://localhost:8099,http://localhost:8080,http://test-mpay.changtu.com,http://172.18.17.60:3000";
        String referStr = "http://172.18.17.60:3000/wap/loginAndRegister/register";   //通过防盗链查看来源主机域名
        Optional<String> opt = Optional.ofNullable(referStr);
        Map map = new HashMap();
        opt.map(s2 -> Stream.of(allowOrigins.split(","))
                .anyMatch(v -> {
                    if(referStr.contains(v)){
                        map.put("ss","11");
                        return true;
                    }else {
                        return false;
                    }
                }));
        System.out.println(map);
    }
}
